<?php

namespace app\common\model;

class Article extends \think\Model
{
    protected $table = 'db_article';

    protected $jsonAssoc = true;

    protected $autoWriteTimestamp = true;

    protected $schema = [
        'id' => 'int',
        'create_time' => 'int',
        'update_time' => 'int',
        'pubid' => 'varchar',
        'sort' => 'int',
        'name' => 'varchar',
        'state' => 'tinyint',
        'type' => 'tinyint',
        'article_class_id' => 'int',
        'member_id' => 'int',
        'is_creating' => 'int',
        'push_time' => 'int',
        'site_id' => 'int',
        'lang' => 'varchar',
        'article_title_task_id' => 'int',
        'forbiddenwords_id' => 'int',
        'length' => 'int',
        'keywords' => 'varchar',
        'article_url' => 'varchar',
        'gpt_id' => 'int',
        'img_class_id' => 'int',
    ];

    public $getters = [
        
    ];

    /**
     * 关联模型articleContent
     */
    public function articleContent()
    {
        return $this->hasOne(ArticleContent::class );
    }

    /**
     * 关联模型pushLog
     */
    public function pushLog()
    {
        return $this->hasMany(PushLog::class );
    }

    /**
     * 关联模型gptRequestLog
     */
    public function gptRequestLog()
    {
        return $this->hasMany(GptRequestLog::class );
    }

    /**
     * 关联模型articleClass
     */
    public function articleClass()
    {
        return $this->belongsTo(ArticleClass::class );
    }

    /**
     * 关联模型member
     */
    public function member()
    {
        return $this->belongsTo(Member::class );
    }

    /**
     * 关联模型site
     */
    public function site()
    {
        return $this->belongsTo(Site::class );
    }

    /**
     * 关联模型articleTitleTask
     */
    public function articleTitleTask()
    {
        return $this->belongsTo(ArticleTitleTask::class );
    }

    /**
     * 推送时间设置器
     */
    public function setPushTimeAttr($value, $data)
    {
        return $value?strtotime($value):0;
    }
}
